﻿@using System.Web
@using Kugar.Core.ExtMethod
@using Kugar.UI.Web.AdminLTE
@using Kugar.UI.Web.AdminLTE.Interfaces
@using Microsoft.AspNetCore.Http.Extensions

@inject AdminLTEUI WebUI

@{
    Layout = null;

    //var schemeName = ViewContext.HttpContext.Items.TryGetValue("SchemeName", "").ToStringEx();

    string logoutUrl  = WebUI.LogoutUrl.IfEmptyOrWhileSpace(AdminLTEUI.DefaultAdminUrls.LogoutUrl);

    if (logoutUrl.LastIndexOf('?') > 0)
    {
        logoutUrl = logoutUrl + "&backurl=" + HttpUtility.UrlEncode(this.Context.Request.GetDisplayUrl());
    }
    else
    {
        logoutUrl = logoutUrl + "?backurl=" + HttpUtility.UrlEncode(this.Context.Request.GetDisplayUrl());
    }

    var userName = (string) ViewBag.UserName;
    var avatarSrc = (string) ViewBag.AvatarSrc;

    if (string.IsNullOrWhiteSpace(userName))
    {
        userName = "Admin";
    }

    if (string.IsNullOrWhiteSpace(avatarSrc))
    {
        avatarSrc = AdminLTEUI.LayoutPath.ResourceBaseUrl + "/Content/lib/adminlte/img/avatar5.png";
    }

    ViewContext.ViewData["IsInPage"] = true;

    var validator = (IClientValidateRender) this.ViewContext.HttpContext.RequestServices.GetService(typeof(IClientValidateRender));
    }
<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">

    <meta name="viewport" content="height=device-height, width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <title>@(ViewContext.HttpContext.Items["PrefixTitle"])@(ViewBag.Title)</title>
    <link href="https://fonts.loli.net/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic" rel="stylesheet" />
    <link href="@(AdminLTEUI.LayoutPath.ResourceBaseUrl)/Content/css/adminbase_base_require.min.css" rel="stylesheet" />



    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
        <script src="@(AdminLTEUI.LayoutPath.ResourceBaseUrl)/Content/lib/html5shiv/html5.min.js"></script>
        <script src="@(AdminLTEUI.LayoutPath.ResourceBaseUrl)/Content/lib/respond/respond.min.js"></script>
    <![endif]-->
    <!-- Google Font -->




    @{
        var validatorCssFiles = validator?.CssFilesUrl();
    }

    @if (validatorCssFiles.HasData())
    {
        foreach (var cssFile in validatorCssFiles)
        {
    <link href="@cssFile" rel="stylesheet">
}
}

<link href="@(AdminLTEUI.LayoutPath.ResourceBaseUrl)/Content/lib/webui_ctrl/all_plugins.css?v=@(AdminLTEUI.InternalFileMD5.webui_ctrl_all_plugins_css)" rel="stylesheet" asp-append-version="true" />

<link href="@(AdminLTEUI.LayoutPath.ResourceBaseUrl)/Content/css/AdminLTEUICSS.css?v=@(AdminLTEUI.InternalFileMD5.AdminLTEUICSS_css)" rel="stylesheet" asp-append-version="true" />

@RenderSection("styles", false)
</head>
<body class="hold-transition skin-blue sidebar-mini">
    <!-- Site wrapper -->
    <div class="wrapper">
        <header class="main-header">
            <!-- Logo -->
            <a href="#" class="logo">
                @if (!this.IsSectionDefined("logo"))
                {
                    <!-- mini logo for sidebar mini 50x50 pixels -->
                    <span class="logo-mini">K</span>
                    <!-- logo for regular state and mobile devices -->
                    <span class="logo-lg">后台管理系统</span>
                }
                else
                {
                    @RenderSection("logo", false)
                }
            </a>
            <!-- Header Navbar: style can be found in header.less -->
            <nav class="navbar navbar-static-top">
                <!-- Sidebar toggle button-->
                <a href="#" class="sidebar-toggle" data-toggle="push-menu" role="button">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </a>
                <div class="navbar-custom-menu">
                    <ul class="nav navbar-nav">
                        <li>
                            <a href="@(logoutUrl)" target="_self">
                                <i class="fa fa-fw fa-sign-out"></i>
                                退出
                            </a>
                        </li>
                    </ul>
                </div>
            </nav>
        </header>
        <!-- =============================================== -->
        <!-- Left side column. contains the sidebar -->
        <aside class="main-sidebar">
            <!-- sidebar: style can be found in sidebar.less -->
            <section class="sidebar">
                <!-- Sidebar user panel -->
                <div class="user-panel" href="@WebUI.UserInfoHref.IfEmptyOrWhileSpace("#")" >
                    <div class="pull-left image">
                        <img src="@avatarSrc" class="img-circle" alt="User Image">
                    </div>
                    <div class="pull-left info">
                        <p>@userName</p>
                        <a><i class="fa fa-circle text-success"></i> 在线</a>
                    </div>
                </div>

                <!-- sidebar menu: : style can be found in sidebar.less -->
                <ul class="sidebar-menu webui_mainmenu" data-widget="tree">
                    <li class="header">网站导航</li>

                    @if (WebUI.Menus.HasData())
                    {
                        foreach (var firstMenu in WebUI.Menus)
                        {
                            if (!firstMenu.IsShow)
                            {
                                continue;
                            }
                            <li class="@firstMenu.ChildMenus.HasData().If("treeview")">
                                <a href="@(firstMenu.GotoUrl.IfEmptyOrWhileSpace("#"))" data-menukey="@firstMenu.Key">
                                    <i class="fa @firstMenu.LogoCss.IfEmptyOrWhileSpace("fa-circle-o")"></i><span>@firstMenu.Title</span>
                                    @if (firstMenu.ChildMenus.HasData())
                                    {
                                        <span class="pull-right-container">
                                            <i class="fa fa-angle-left pull-right"></i>
                                            @if (!string.IsNullOrWhiteSpace(firstMenu.Badge))
                                            {
                                                <small class="label pull-right bg-red">@firstMenu.Badge</small>
                                            }
                                        </span>
                                    }
                                </a>
                                @if (firstMenu.ChildMenus.HasData())
                                {
                                    <ul class="treeview-menu">
                                        @foreach (var secMenu in firstMenu.ChildMenus)
                                        {
                                            if (!secMenu.IsShow)
                                            {
                                                continue;
                                            }

                                            <li class="@secMenu.ChildMenus.HasData().If("treeview")">
                                                <a href="@secMenu.GotoUrl.IfEmptyOrWhileSpace("#")" data-menukey="@secMenu.Key">
                                                    <i class="fa @secMenu.LogoCss.IfEmptyOrWhileSpace("fa-circle-o")"></i><span>@secMenu.Title</span>
                                                    @if (secMenu.ChildMenus.HasData())
                                                    {
                                                        <span class="pull-right-container">
                                                            <i class="fa fa-angle-left pull-right"></i>
                                                            @if (!string.IsNullOrWhiteSpace(secMenu.Badge))
                                                            {
                                                                <small class="label pull-right bg-red">@secMenu.Badge</small>
                                                            }
                                                        </span>
                                                    }
                                                </a>
                                                @if (secMenu.ChildMenus.HasData())
                                                {
                                                    <ul class="treeview-menu">
                                                        @foreach (var thrMenu in secMenu.ChildMenus)
                                                        {
                                                            if (!thrMenu.IsShow)
                                                            {
                                                                continue;
                                                            }

                                                            <li>
                                                                <a href="@thrMenu.GotoUrl.IfEmptyOrWhileSpace("#")" data-menukey="@thrMenu.Key">
                                                                    <i class="fa @thrMenu.LogoCss.IfEmptyOrWhileSpace("fa-circle-o")"></i><span>@thrMenu.Title</span>

                                                                    @if (!string.IsNullOrWhiteSpace(secMenu.Badge))
                                                                    {
                                                                        <span class="pull-right-container">
                                                                            <small class="label pull-right bg-red">@secMenu.Badge</small>
                                                                        </span>
                                                                    }

                                                                </a>
                                                            </li>
                                                        }
                                                    </ul>
                                                }
                                            </li>
                                        }
                                    </ul>
                                }
                            </li>
                        }
                    }

                </ul>
            </section>
            <!-- /.sidebar -->
        </aside>
        <!-- =============================================== -->
        <!-- Content Wrapper. Contains page content -->
        <div class="content-wrapper" id="content-wrapper" style="min-height: 421px;">

            @if (!WebUI.IsIFrameVersion)
            {
                <section class="content-header">
                    <h1 class="title">
                        @WebUI.Title
                        <small>@WebUI.Subtitle</small>
                    </h1>

                    @if (WebUI.Breadcrumbs.HasData())
                    {
                        <ol class="breadcrumb">
                            @for (int i = 0; i < WebUI.Breadcrumbs.Length; i++)
                            {
                                var item = WebUI.Breadcrumbs[i];

                                <li class="@((i == WebUI.Breadcrumbs.Length - 1) ? "active" : "")">
                                    <a href="@item.Href.IfEmptyOrWhileSpace("#")">
                                        @if (i == 0)
                                        {
                                            <i class="fa fa-dashboard"></i>
                                        }
                                        @item.Title
                                    </a>
                                </li>
                            }
                        </ol>
                    }


                </section>
                <!-- Main content -->
                <section class="content">
                    <div class="content-body">
                        @RenderBody()

                        <div class="clearfix"></div>
                    </div>
                    <div class="clearfix"></div>
                </section>
                <!-- Content Header (Page header) -->
                <!-- /.content -->
                <div class="clearfix"></div>
            }
            else
            {
                @RenderBody()
            }

            <div class="clearfix"></div>
        </div>
        <!-- /.content-wrapper -->
        <footer class="main-footer">
            <div class="pull-right hidden-xs">
                <b>Version:</b> v@(WebUI.Version) &nbsp;&nbsp;&nbsp;
                <b>AdminLTE:</b> 2.4.3
            </div>
            @RenderSection("footer", false)

            <div class="clearfix"></div>
        </footer>


    </div>
    <!-- ./wrapper -->

    <script src="@(AdminLTEUI.LayoutPath.ResourceBaseUrl)/Content/js/adminbase_base_require.min.js"></script>
    <script src="@(AdminLTEUI.LayoutPath.ResourceBaseUrl)/Content/lib/layui/layui.js"></script>
    


@{
        var validatorScripts = validator?.Scripts().ToArrayEx();
    }
    @if (validatorScripts.HasData())
    {
        foreach (var url in validatorScripts)
        {
            <script src="@url"></script>
        }
    }
    
    <script src="@(AdminLTEUI.LayoutPath.ResourceBaseUrl)/Content/lib/webui_ctrl/all_plugins.js?v=@(AdminLTEUI.InternalFileMD5.webui_ctrl_all_plugins_js)"></script>

    <script src="@(AdminLTEUI.LayoutPath.ResourceBaseUrl)/Content/js/WebUIJS.js?v=@(AdminLTEUI.InternalFileMD5.WebUIJS_js)"></script>

    <script>
    @{
        validator?.Render(ViewContext);
    }
    </script>

    <script>
    //layui.use('layer',
    //    function() {
    //        layer = layui.layer;
    //        layui.layer.load();
    //    });

    WebUIJS.ResourceUrl = "@AdminLTEUI.LayoutPath.ResourceBaseUrl";

    $(document).ready(function() {
        $('.sidebar-menu').tree();


        var currentMenuKey = '@WebUI.CurrentMenuKey';

        layui.use('layer',
            function() {
                layer = layui.layer;
                layui.layer.load();

                WebUIJS.RefreshEvent($("body"),
                    function() {
                        layui.use('layer',
                            function() {
                                layui.layer.closeAll('loading'); //关闭加载层
                            });

                        WebUIJS.SetActiveMenuKey(currentMenuKey);
                    });
            });


    });
    </script>

    @RenderSection("scripts", false)


    @WebUI.SystemComponent.ServerMsg().Render()

</body>
</html>